# -*-encoding: Utf-8 -*-
# author: 黄景涛
# Time：2025/3/12
import time

class InfiniteIterator:
    def __init__(self, start=0):
        self.start = start

    def __iter__(self):
        return self

    def __next__(self):
        cur_num = self.start
        self.start += 1
        return cur_num


if __name__ == '__main__':
    inf_counter = InfiniteIterator()
    print(f"迭代器实例：{inf_counter}")
    for num in inf_counter:
        print(num)
        time.sleep(0.5)

        # 第三方代码介入，强制终止迭代
        if inf_counter.start > 10:
            break
